package com.hk.developmentlib.utills;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.hk.developmentlib.cache.SimpleDiskCache;
import com.hk.developmentlib.utills.des.Des;


import org.apache.commons.codec.binary.StringUtils;
import org.xutils.common.util.LogUtil;
import org.xutils.http.RequestParams;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * 字符串操作工具包
 */
@SuppressLint("SimpleDateFormat")
public class StringHelper {


    public static String getDESString(String content) {
        try {
            content = Des.encryptDES(content, SimpleDiskCache.YJ_DES_KEY);
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.e("错误原因" + e.getMessage());
        }
        return content;
    }



    public static RequestParams getRequestParamstData(Map<String, String> reqParam) {

        String data = FastjsonUtils.toJSONString(reqParam);
        LogUtil.e(data);
        data = StringHelper.getDESString(data);
        LogUtil.e(data);
        RequestParams params = new RequestParams();
        params.addBodyParameter("data", data);

        return params;

    }




    private final static Pattern emailer = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
    // private final static SimpleDateFormat dateFormater = new
    // SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // private final static SimpleDateFormat dateFormater2 = new
    // SimpleDateFormat("yyyy-MM-dd");

    private final static ThreadLocal<SimpleDateFormat> dateFormater_YMDHMS = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return DateUtils.YMDHMS_ENGLISH;
        }
    };

    private final static ThreadLocal<SimpleDateFormat> dateFormater_YMD = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return DateUtils.YMD_ENGLISH;
        }
    };

    private final static ThreadLocal<SimpleDateFormat> dateFormater_MD = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return DateUtils.MD_ENGLISH;
        }
    };

    /**
     * 将字符串转位日期类型
     *
     * @param sdate
     * @return
     */
    public static Date toDate(String sdate) {
        try {
            return dateFormater_YMDHMS.get().parse(sdate);
        } catch (ParseException e) {
            return null;
        }
    }

    public static Date toDateYMD(String sdate) {
        try {
            return dateFormater_YMD.get().parse(sdate);
        } catch (ParseException e) {
            return null;
        }
    }


    /**
     * 以友好的方式显示时间
     *
     * @param sdate
     * @return
     */

    public static String friendlyPubTime(long sdate) {
        Date date = new Date(sdate);
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//部分机型不能生成包含：文件名的文件
        String Stime = f.format(date);

        Stime = friendlyPubTime(Stime);
        return Stime;
    }

    private static String getMoringAfternoonNight(Date date) {
        String dayTime = "";
        int dayInHour = (int) (date.getTime() / 3600000 + 8) % 24;
        LogUtil.d("dayInHour" + dayInHour);
        LogUtil.d("date" + date.getTime());
        if (dayInHour < 4) {
            dayTime = "凌晨";
        } else if (dayInHour < 9) {
            dayTime = "早晨";
        } else if (dayInHour < 12) {
            dayTime = "上午";
        } else if (dayInHour < 14) {
            dayTime = "中午";
        } else if (dayInHour < 18) {
            dayTime = "下午";
        } else if (dayInHour < 23) {
            dayTime = "晚上";
        } else if (dayInHour < 24) {
            dayTime = "深夜";
        }
        return "";
    }

    public static String friendlyPubTime(String sdate) {
        Date time = toDate(sdate);
        if (time == null) {
            return "Unknown";
        }
        String ftime = "";
        Calendar cal = Calendar.getInstance();
        // 判断是否是同一天
        String curDate = dateFormater_YMD.get().format(cal.getTime());
        String paramDate = dateFormater_YMD.get().format(time);
        if (curDate.equals(paramDate)) {
            int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
            if (hour == 0)
                ftime = Math.max((cal.getTimeInMillis() - time.getTime()) / 60000, 1) + "分钟前";
            else
                ftime = hour + "小时前";
            return ftime;
        }
//        long lt = time.getTime() / 86400000;
//        long ct = cal.getTimeInMillis() / 86400000;
//        int days = (int) (ct - lt);
        long lt = toDateYMD(paramDate).getTime();
        long ct = toDateYMD(curDate).getTime();
        int days = (int) ((ct - lt) / 86400000);

        if (days == 0) {
            int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
            if (hour == 0)
                ftime = Math.max((cal.getTimeInMillis() - time.getTime()) / 60000, 1) + "分钟前";
            else
                ftime = hour + "小时前";
        } else if (days == 1) {
            ftime = "昨天" + getMoringAfternoonNight(time);
        } else if (days == 2) {
            ftime = "前天" + getMoringAfternoonNight(time);
        } else if (days > 2 && days <= 10) {
            ftime = days + "天前" + getMoringAfternoonNight(time);
        } else if (days > 10) {
            ftime = dateFormater_MD.get().format(time) + getMoringAfternoonNight(time);
        }
        return ftime;
    }

//    public static String friendlyDate(Date date) {
//
//        Date now = new Date();
//        long ys = DateUtils.truncate(now, Calendar.YEAR).getTime();
//        long ds = DateUtils.truncate(now, Calendar.DAY_OF_MONTH).getTime();
//        long yd = DateUtils.truncate(date, Calendar.DAY_OF_MONTH).getTime();
//
//        long n = now.getTime();
//
//        long e = date.getTime();
//        if (e < ys) {
//            return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
//        }
//        if ((ds - yd) == (24 * 60 * 60 * 1000)) {
//            return new SimpleDateFormat("昨天  HH:mm").format(date);
//        }
//        if (e < ds) {
//            return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
//        }
//        if (n - e > 60 * 60 * 1000) {
//            return new SimpleDateFormat("今天  HH:mm").format(date);
//        }
//        if (n - e > 60 * 1000) {
//            return (long) Math.floor((n - e) * 1d / 60000) + "分钟前";
//        }
//        if (n - e > 1 * 1000) {
//            return "刚刚";
//        }
//        return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
//    }

    /**
     * 以友好的方式显示时间
     *
     * @param
     * @return
     */

    public static String getNormalTimeString(long time) {

        Date date = new Date(time);
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm");//部分机型不能生成包含：文件名的文件
        String Stime = f.format(date);

        return Stime;
    }

    public static String getNormalTimeYMD(long time) {

        Date date = new Date(time);
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");//部分机型不能生成包含：文件名的文件
        String Stime = f.format(date);

        return Stime;
    }


    public static String getNormalTimeNYR(long time) {

        Date date = new Date(time);
        SimpleDateFormat f = new SimpleDateFormat("MM月dd日 HH:mm");//部分机型不能生成包含：文件名的文件
        String Stime = f.format(date);

        return Stime;
    }

    public static String getNormalTimeNYRString2(long time) {

        Date date = new Date(time);
        SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");//部分机型不能生成包含：文件名的文件
        String Stime = f.format(date);

        return Stime;
    }


    public static String getNormalTimeNYRString3(long time) {

        Date date = new Date(time);
        SimpleDateFormat f = new SimpleDateFormat("yy年MM月dd日 HH:mm");//部分机型不能生成包含：文件名的文件
        String Stime = f.format(date);

        return Stime;
    }

    public static String getNormalTimeStringToMin(int time) {
        if (time == 0) {
            return "未知";
        }

        Long ltime = Long.valueOf(String.valueOf(time * 1000L));
        Date date = new Date(ltime);
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String Stime = f.format(date);

        return Stime;
    }

    public static String getRecordMonthAndYear(int time) {
        if (time == 0) {
            return "未知";
        }

        SimpleDateFormat f_year = new SimpleDateFormat("yyyy");
        SimpleDateFormat f_month = new SimpleDateFormat("MM月");
        SimpleDateFormat f_year_month = new SimpleDateFormat("yyyy年MM月");
        long now = System.currentTimeMillis();
        String nowyear = f_year.format(new Date(now));
        String year = f_year.format(new Date(time * 1000L));
        if (nowyear.equals(year)) {
            return f_month.format(new Date(time * 1000L));
        } else {
            return f_year_month.format(new Date(time * 1000L));
        }

    }


    public static String getTimeString(int time) {
        if (time == 0) {
            return "未知";
        }

        Long ltime = Long.valueOf(String.valueOf(time * 1000L));
        Date date = new Date(ltime);
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String Stime = friendlyPubTime(f.format(date));

        return Stime;
    }

    /**
     * 判断给定字符串时间是否为今日
     *
     * @param sdate
     * @return boolean
     */
    public static boolean isToday(String sdate) {
        boolean b = false;
        Date time = toDate(sdate);
        Date today = new Date();
        if (time != null) {
            String nowDate = dateFormater_YMD.get().format(today);
            String timeDate = dateFormater_YMD.get().format(time);
            if (nowDate.equals(timeDate)) {
                b = true;
            }
        }
        return b;
    }

    /**
     * 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串，返回true
     *
     * @param input
     * @return boolean
     */
    public static boolean isEmpty(String input) {
        if (input == null || "".equals(input))
            return true;

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
                return false;
            }
        }
        return true;
    }

    public static boolean isRightNum(String num) {
        if (num.endsWith(".")) {
            return false;
        }
        if (Double.parseDouble(num) >= 1) {

            return true;
        }

        return false;

    }

    public static boolean isNumeric(String str) {
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }
        return true;
    }

    /**
     * 判断是不是一个合法的电子邮件地址
     *
     * @param email
     * @return
     */
    public static boolean isEmail(String email) {
        if (email == null || email.trim().length() == 0)
            return false;
        return emailer.matcher(email).matches();
    }

    /**
     * 判断手机格式是否正确
     *
     * @param mobiles
     * @return
     */
    public static boolean isMobileNO(String mobiles) {

//        // Pattern p = Pattern
//        //
//        // .compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
//
//        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,3-9]))\\d{8}$");
//
//        // Pattern p =
//        // Pattern.compile("^((13)|(15[0-3,5-9])|(145)|(147)|(17[0678])|(18[0-9]))\\d{8}$");
//        Matcher m = p.matcher(mobiles);
//
//        return m.matches();
        if (TextUtils.isEmpty(mobiles) || mobiles.length() != 11 || !mobiles.startsWith("1")) {
            return false;
        } else {
            return true;
        }

    }

    /**
     * 判断身份证格式 需要验证15位以及18位身份证
     *
     * @param id
     * @return
     */
    public static boolean isIDCard(String id) {
        Pattern patternSfzhm1 = Pattern.compile("^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{4}$");
        Pattern patternSfzhm2 = Pattern.compile("^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$");
        Matcher matcherSfzhm1 = patternSfzhm1.matcher(id);
        Matcher matcherSfzhm2 = patternSfzhm2.matcher(id);

        return matcherSfzhm1.find() || matcherSfzhm2.find();

    }

    /**
     * 判断邮编格式是否正确
     *
     * @param //mobiles
     * @return
     */
    public static boolean isZipNO(String zipString) {
        String str = "^[1-9][0-9]{5}$";
        return Pattern.compile(str).matcher(zipString).matches();
    }

    /**
     * 不同于其他的转化，这个是将任意字符串，即非数字型字符串，转成唯一的int类型数据
     *
     * @param str
     * @return
     */
    /*
     * public static int string2IntMd5(String str) { String md5 =
	 * Md5Utils.md516One(str); return string2IntBase(md5); }
	 */
    public static int string2IntBase(String str) {
        char[] ch = str.toCharArray();
        int result = 0;
        for (int i = 0; i < ch.length; i++) {
            int tmp = ch[i];
            result += (ch.length - i) * tmp;
        }

        return result;
    }

    /**
     * 字符串转整数
     *
     * @param str
     * @param defValue
     * @return
     */
    public static int toInt(String str, int defValue) {
        try {
            return Integer.parseInt(str);
        } catch (Exception e) {
        }
        return defValue;
    }

    /**
     * 对象转整数
     *
     * @param obj
     * @return 转换异常返回 0
     */
    public static int toInt(Object obj) {
        if (obj == null)
            return 0;
        return toInt(obj.toString(), 0);
    }

    /**
     * 对象转整数
     *
     * @param obj
     * @return 转换异常返回 0
     */
    public static long toLong(String obj) {
        try {
            return Long.parseLong(obj);
        } catch (Exception e) {
        }
        return 0;
    }

    /**
     * 字符串转布尔值
     *
     * @param b
     * @return 转换异常返回 false
     */
    public static boolean toBool(String b) {
        try {
            return Boolean.parseBoolean(b);
        } catch (Exception e) {
        }
        return false;
    }


    public static String capitalize(String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return str;
        }
        return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1)).toString();
    }

    public static String stringToUnicode(String str) {
        if (isEmpty(str))
            return null;
        StringBuffer strb = new StringBuffer();
        for (int i = 0; i < str.length(); i++) {
            if (strb.length() == 0) {
                strb.append(Integer.toHexString(str.charAt(i)));
            } else {
                strb.append("-").append(Integer.toHexString(str.charAt(i)));
            }
        }
        return strb.toString();
    }

    public static String unicodeToString(String str) {
        if (isEmpty(str))
            return null;

        Pattern pattern = Pattern.compile("(\\-(\\p{XDigit}{4}))");
        Matcher matcher = pattern.matcher(str);
        char ch;
        while (matcher.find()) {
            ch = (char) Integer.parseInt(matcher.group(2), 16);
            str = str.replace(matcher.group(1), ch + "");
        }
        return str;
    }

    public static String unicodeToString2(String str) {
        if (isEmpty(str))
            return null;
        String[] arr = str.split("-");
        StringBuilder sb = new StringBuilder();

        char ch;
        for (String s : arr) {
            ch = (char) Integer.parseInt(s, 16);
            sb.append(ch);
        }
        return sb.toString();
    }

    /**
     * java字节码转字符串
     *
     * @param b
     * @return
     */

    @SuppressLint("DefaultLocale")
    public static String byte2hex(byte[] b) { // 一个字节的数，

        // 转成16进制字符串

        String hs = "";

        String tmp = "";

        for (int n = 0; n < b.length; n++) {

            // 整数转成十六进制表示

            tmp = (Integer.toHexString(b[n] & 0XFF));

            if (tmp.length() == 1) {

                hs = hs + "0" + tmp;

            } else {

                hs = hs + tmp;

            }

        }

        tmp = null;

        return hs.toLowerCase(); // 转成小写

    }

    /**
     * 提示输入内容超过规定长度
     *
     * @param context
     * @param editText
     * @param max_length
     * @param err_msg
     */
    public static void setLengthFilter(final Context context, EditText editText, final int max_length, final String err_msg) {

        InputFilter[] filters = new InputFilter[1];
        filters[0] = new InputFilter.LengthFilter(max_length) {

            @Override
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
                // TODO Auto-generated method stub
                // 获取字符个数(一个中文算2个字符)
                int destLen = StringHelper.getCharacterNum(dest.toString());
                int sourceLen = StringHelper.getCharacterNum(source.toString());
                if (destLen + sourceLen > max_length) {
                    Toast.makeText(context, err_msg, Toast.LENGTH_SHORT).show();
                    return "";
                }
                return source;
            }

        };
        editText.setFilters(filters);
    }

    /**
     * 获取字符长度
     *
     * @param content
     * @return
     */
    public static int getCharacterNum(String content) {
        if (content.equals("") || null == content) {
            return 0;
        } else {
            return content.length() + getChineseNum(content);
        }

    }

    /**
     * 计算字符串的中文长度
     *
     * @param s
     * @return
     */
    public static int getChineseNum(String s) {
        int num = 0;
        char[] myChar = s.toCharArray();
        for (int i = 0; i < myChar.length; i++) {
            if ((char) (byte) myChar[i] != myChar[i]) {
                num++;
            }
        }
        return num;
    }

    /**
     * 此方法为字符串头部跟尾部拼上#号
     *
     * @param tag
     * @return
     */
    public static String createTag(String tag) {
        if (!tag.startsWith("#")) {
            tag = "#" + tag;
        }
        if (!tag.endsWith("#")) {
            tag = tag + "#";
        }
        return tag;
    }

    /**
     * 获取标签
     *
     * @param content
     * @return
     */
    public static String getTags(String content) {
        if (TextUtils.isEmpty(content)) {
            return null;
        }
        Pattern pattern = Pattern.compile("#(.*?)#");
        Matcher matcher = pattern.matcher(content);
        StringBuffer buffer = new StringBuffer();
        while (matcher.find()) {
            String tag = matcher.group();
            if (buffer.length() != 0) {
                buffer.append(" ");
            }
            buffer.append(tag);
        }
        String tags = buffer.toString();
        LogUtil.i("tag:" + tags);
        return tags;
    }

    /**
     * 获取各个标签在字符串中的位置
     *
     * @param content
     * @return
     */
    public static List<TagInfo> getTagInfo(String content) {
        List<TagInfo> tagInfos = new ArrayList<TagInfo>();
        if (TextUtils.isEmpty(content)) {
            return tagInfos;
        }
        Pattern pattern = Pattern.compile("#(.*?)#");
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            String group = matcher.group();
            int end = matcher.end();
            int start = end - group.length();
            TagInfo tagInfo = new TagInfo();
            tagInfo.setStart(start);
            tagInfo.setEnd(end);
            tagInfo.setName(group);
            tagInfos.add(tagInfo);

        }
        return tagInfos;
    }

    /**
     * 标签信息
     *
     * @author csf
     */
    public static class TagInfo {

        /**
         * 标签
         */
        private String name;
        /**
         * 开始索引
         */
        private int start;

        /**
         * 结束索引
         */
        private int end;

        /**
         * @return the start
         */
        public int getStart() {
            return start;
        }

        /**
         * @param start the start to set
         */
        public void setStart(int start) {
            this.start = start;
        }

        /**
         * @return the end
         */
        public int getEnd() {
            return end;
        }

        /**
         * @param end the end to set
         */
        public void setEnd(int end) {
            this.end = end;
        }

        @Override
        public String toString() {
            return "Position [start=" + start + ", end=" + end + "]";
        }

        /**
         * @return the name
         */
        public String getName() {
            return name;
        }

        /**
         * @param name the name to set
         */
        public void setName(String name) {
            this.name = name;
        }

    }


    public static String replaceStringCode(String content) {

        content = content.replaceAll("&amp;", "");

        content = content.replaceAll("&quot;", "\"");
        content = content.replaceAll("quot;", "\"");

        content = content.replaceAll("&lt;", "<");
        content = content.replaceAll("lt;", "<");

        content = content.replaceAll("&gt;", ">");
        content = content.replaceAll("gt;", ">");

        content = content.replaceAll("&nbsp;", "");
        content = content.replaceAll("nbsp;", "");
        content = content.replaceAll("_ueditor_page_break_tag_", "");

        //
        // String regex = "width=\"[0-9]{3}\"";
        // String regex2 = "style=\"width:[0-9]{3}px\"";
        //
        // content = content.replaceAll(regex,"width=\"350\"");

        return content;
    }

    public static String replaceStringCodeP(String content) {

        content = content.replaceAll("<p>", "");
        content = content.replaceAll("</p>", "");

        //
        // String regex = "width=\"[0-9]{3}\"";
        // String regex2 = "style=\"width:[0-9]{3}px\"";
        //
        // content = content.replaceAll(regex,"width=\"350\"");

        return content;
    }

    public static String getHMSTSpeedByCount(int count) {

        int time = count;
        int hour = time / 3600;
        int min = (time - hour * 3600) / 60;
        int sec = time - hour * 3600 - 60 * min;


        String hourText = "";
        String minText = "";
        String secText = "";
        if (hour != 0) {
            hourText = String.valueOf(hour) + "°";
        }

        if (min > 0 && min < 10) {
            minText = "0" + String.valueOf(min) + "'";
        } else if (min >= 10) {
            minText = String.valueOf(min) + "'";
        } else {
            minText = "00'";
        }
        if (sec > 0 && sec < 10) {
            secText = "0" + String.valueOf(sec) + "\"";
        } else if (sec >= 10) {
            secText = String.valueOf(sec) + "\"";
        } else {
            secText = "00\"";
        }

        return hourText + minText + secText;

    }

    public static String getHMSTSpeed(double speed) {

        int time = (int) (speed * 60);
        int hour = time / 3600;
        int min = (time - hour * 3600) / 60;
        int sec = time - hour * 3600 - 60 * min;
//        LogUtil.d("speed：" + speed);
//        LogUtil.d("min：" + min);
//        LogUtil.d("sec：" + sec);

        String hourText = "";
        String minText = "";
        String secText = "";
        if (hour != 0) {
            hourText = String.valueOf(hour) + "°";
        }

        if (min > 0 && min < 10) {
            minText = "0" + String.valueOf(min) + "'";
        } else if (min >= 10) {
            minText = String.valueOf(min) + "'";
        } else {
            minText = "00'";
        }
        if (sec > 0 && sec < 10) {
            secText = "0" + String.valueOf(sec) + "\"";
        } else if (sec >= 10) {
            secText = String.valueOf(sec) + "\"";
        } else {
            secText = "00\"";
        }
        LogUtil.d("secText：" + secText);
        return hourText + minText + secText;

    }

    public static String getMinSec(long time) {
        if (time == 0) {
            return "未知";
        }
        Date date = new Date(time);
        SimpleDateFormat f = new SimpleDateFormat("mm:ss");
        String Stime = f.format(date);
        return Stime;
    }


    public static String getHMSTime(int time) {
        int hour = time / 3600;
        int min = (time - hour * 3600) / 60;
        int sec = time - hour * 3600 - 60 * min;
        String hourText = "";
        String minText = "";
        String secText = "";
        if (hour < 10) {
            hourText = "0" + hour;
        } else {
            hourText = String.valueOf(hour);
        }

        if (min < 10) {
            minText = "0" + min;
        } else {
            minText = String.valueOf(min);
        }
        if (sec < 10) {
            secText = "0" + sec;
        } else {
            secText = String.valueOf(sec);
        }


        return hourText + ":" + minText + ":" + secText;

    }


    public static String getHMSDateByDFTimer(String Timer) {
        int hourIndex = Timer.indexOf(":");
        int minIndex = Timer.lastIndexOf(":");
        int secIndex = Timer.length();
        int hour = Integer.parseInt(Timer.substring(0, hourIndex));

        int min = Integer.parseInt(Timer.substring(hourIndex + 1, minIndex));

        int sec = Integer.parseInt(Timer.substring(minIndex + 1, secIndex));
        String hourText = "";
        String minText = "";
        String secText = "";
        if (hour > 0) {
            hourText = hour + "小时";
        }
        if (min > 0) {
            minText = min + "分钟";
        }
        if (sec > 0) {
            secText = sec + "秒";
        }
        return hourText + minText + secText;
    }

    public static String getHMSDate(int time) {
        int hour = time / 3600;
        int min = (time - hour * 3600) / 60;
        int sec = time - hour * 3600 - 60 * min;
        String hourText = "";
        String minText = "";
        String secText = "";
        if (hour > 0) {
            hourText = hour + "小时";
        }
        if (min > 0) {
            minText = min + "分钟";
        }
        if (sec > 0) {
            secText = sec + "秒";
        }


        return hourText + minText + secText;

    }

}
